export const getIdentify = (value) => {
  const routeStore = useRouteStore();
  const { powers } = routeStore;
  let roleMap: any = {};
  let modulesFiles: any = import.meta.glob(["@/api/**/*.ts"], {
    eager: true,
  });
  for (const modulePath in modulesFiles) {
    let moduleName: any = modulePath
      ?.split("/")
      ?.pop()
      ?.replace(/\.\w+$/, "");
    if (!modulesFiles[modulePath] || !modulesFiles[modulePath]?.default?.role)
      continue;
    roleMap[moduleName] = modulesFiles[modulePath]?.default?.role;
  }
  if (isString(value)) {
    let tmp = value?.split(".");
    const identify = roleMap?.[tmp[0]]?.[tmp[1]] ?? "";
    if (tmp.length == 2 && tmp[0] && tmp[1] && roleMap[tmp[0]] && identify)
      if (powers.includes(identify)) return identify;
  }
  return "";
};
export const isHasPower = (value) => {
  let flag = false;
  const identify = getIdentify(value);
  if (!!identify) flag = true;
  return flag;
};
